package cn.enilu.flash.warpper;

import cn.enilu.flash.bean.entity.park.ParkingQuote;
import cn.enilu.flash.conf.properties.LocalFileProperties;
import cn.enilu.flash.enums.body.QuoteType;
import cn.enilu.flash.enums.body.QuoteUnit;
import cn.enilu.flash.service.system.impl.ConstantFactory;
import cn.enilu.flash.utils.DateUtil;
import cn.enilu.flash.utils.StringUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/11/09 13:09)
 * @Version v1.0
 * @Modify
 **/
public class ParkingContractWarpper extends BaseControllerWarpper{

    private LocalFileProperties localFileProperties;

    public ParkingContractWarpper(List<Map<String, Object>> list, LocalFileProperties localFileProperties) {
        super(list);
        this.localFileProperties = localFileProperties;
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
        if(StringUtils.isNotNullOrEmpty(map.get("parkingId"))) {
            map.put("parkingCode", ConstantFactory.me().getParkingCodeById((Long) map.get("parkingId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("custId"))) {
            map.put("custName", ConstantFactory.me().getCustNameById((Long) map.get("custId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("communityId"))) {
            map.put("communityName", ConstantFactory.me().getCommunityNameById((Long) map.get("communityId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("contractFileId"))) {
            map.put("contractFileUrl", localFileProperties.getUrl() + ConstantFactory.me().getFilePathById((Long) map.get("contractFileId")));
        }
        map.put("quoteTypeName", QuoteType.valueOfCode((Integer) map.get("quoteType")));
        map.put("quoteUnitName", QuoteUnit.valueOfCode((Integer) map.get("quoteUnit")));
        if(StringUtils.isNotNullOrEmpty(map.get("signDate"))) {
            map.put("signDateStr", DateUtil.getDay((Date) map.get("signDate")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("startDate"))) {
            map.put("startDateStr", DateUtil.getDay((Date) map.get("startDate")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("endDate"))) {
            map.put("endDateStr", DateUtil.getDay((Date) map.get("endDate")));
        }
    }
}
